<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .wrapper {
            width: 840px;
            height: 420px;
            background: url(./images/bg01.jpg) no-repeat center / cover;
            padding: 100px 250px;
            box-sizing: border-box;
        }
    </style>
</head>

<body>
    <div class="wrapper">
        <strong>班级打扫除大抽奖</strong>
        <h1>一等奖：<span id="one">???</span></h1>
        <h3>二等奖：<span id="two">???</span></h3>
        <h5>三等奖：<span id="three">???</span></h5>
    </div>
    <script>
        // 1.声明数组
        let studentNames = ["马嘉祺", "丁程鑫", "宋亚轩", "刘耀文", "张真源", "严浩翔", "贺峻霖"];
        // 2. 先做一等奖
        // 2.1 随机数 数组的下标
        xxm = Math.floor(Math.random() * studentNames.length)
        // 2.2 获取one 元素 
        let one = document.querySelector('#one')
        // 2.3 把名字给 one
        one.innerText = studentNames[xxm]
        // 2.4 删除数组这个名字
        studentNames.splice(xxm,1)
        //  照样完成二三等奖


        // 二等奖
        xxm = Math.floor(Math.random() * studentNames.length)
        let two = document.querySelector('#two')
        two.innerText = studentNames[xxm]
        studentNames.splice(xxm,1)

        // 三等奖
        xxm = Math.floor(Math.random() * studentNames.length)
        let three = document.querySelector('#three')
        three.innerText = studentNames[xxm]
        studentNames.splice(xxm,1)
    </script>
</body>

</html>